package com.sfy.controller;

import com.sfy.pojo.PageBean;
import com.sfy.pojo.Result;
import com.sfy.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;

@RestController
@Slf4j
@RequestMapping(value = "/emps")
public class EmpController {

    @Autowired
    private EmpService empService;

    //分页查询
    @GetMapping(value = "/emps")
    public Result selectByPage(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize,
            String name,
            Short gender,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDateTime end
    )
    {

        PageBean pageBean = empService.selectByPage(page,pageSize,name,gender,begin,end);
        return Result.success(pageBean);
    }

}
